package controllers.listeners.feature;

import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.ArrayList;

import objects.Constituent;
import objects.Lexicon;
import views.ViewFeatures;

/* Loads the labels and data under the selected semantic representation / lexicon */
/* actionPerformed when you click the Semantic Representation / Lexicon combobox */
public class FeatureNavigationByTypeItemListener implements ItemListener{

	private ViewFeatures view;
	private ArrayList<Constituent> constituents;
	private ArrayList<Lexicon> lexicons;
	
	public FeatureNavigationByTypeItemListener(ArrayList<Constituent> constituents, ArrayList<Lexicon> lexicons) {
		this.constituents = constituents;
		this.lexicons = lexicons;
		view = null;
	}
	
	public void setView(ViewFeatures view) {
		this.view = view;
	}
	
	@Override
	public void itemStateChanged(ItemEvent arg0) {
		if (arg0.getStateChange() == ItemEvent.SELECTED) {
			view.clearCombo();
			
			if(view.getSelectedFeatureType().equals("Semantic Rep")) {
				view.setConstituentsForChooser(constituents);
				view.loadConstituent(constituents.get(0));
			}
			
			else if(view.getSelectedFeatureType().equals("Lexicon")) {
				view.setLexiconsForChooser(lexicons);
				view.loadLexicon(lexicons.get(0));
			}
		}
		
	}

}
